package com.zhangxu.microservice.system.web.convert;

import com.zhangxu.microservice.common.utils.AesEncryptUtils;
import com.zhangxu.microservice.common.utils.DesensitizationUtils;
import com.zhangxu.microservice.system.biz.dto.CreateEmployeeDTO;
import com.zhangxu.microservice.system.biz.dto.EmployeeDTO;
import com.zhangxu.microservice.system.web.request.CreateEmployeeReq;
import com.zhangxu.microservice.system.web.response.EmployeeResp;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;

@Mapper(componentModel = "spring")
public interface EmployeeConverter {

    @Mapping(target = "passwordCrypto", ignore = true)
    @Mapping(target = "phoneCrypto", ignore = true)
    CreateEmployeeDTO toCreateEmployeeDTO(CreateEmployeeReq createUserRequest);

//    EmployeeAuthDTO toEmployeeAuthDTO(EmployeeDTO userDTO);

    @Mapping(target = "phone", source = "phoneCrypto", qualifiedByName = "desensitizePhone")
    EmployeeResp dto2EmployeeResp(EmployeeDTO dto);

    @Named("desensitizePhone")
    static String desensitizePhone(String phone) {
        return DesensitizationUtils.desensitizePhone(AesEncryptUtils.decrypt(phone));
    }
//
//    EmployeeApiDTO toEmployeeDTO(EmployeeDTO userDTO);
//
//    List<EmployeeApiDTO> toEmployeeDTOList(List<EmployeeDTO> employeeDTOList);
}
